import Slot from "../layouts/Slot";
import { PdfJs, PluginFunctions } from "../interface";
import LayerRenderStatus from "./LayerRenderStatus";
import RenderViewer from "./RenderViewer";
import ViewerState from "./ViewerState";
import { ReactElement } from "react";

export interface PluginOnDocumentLoad {
  doc: PdfJs.PdfDocument;
}

export interface PluginOnTextLayerRender {
  ele: HTMLElement;
  pageIndex: number;
  scale: number;
  status: LayerRenderStatus;
}

export interface PluginOnAnnotationLayerRender {
  annotations: PdfJs.Annotation[];
  container: HTMLElement;
  pageIndex: number;
  scale: number;
  rotation: number;
}

export interface PluginOnCanvasLayerRender {
  ele: HTMLCanvasElement;
  pageIndex: number;
  rotation: number;
  scale: number;
  status: LayerRenderStatus;
}

export interface PluginRenderPageLayer {
  doc: PdfJs.PdfDocument;
  height: number;
  pageIndex: number;
  rotation: number;
  scale: number;
  width: number;
}

export interface Plugin {
  install?(pluginFunctions: PluginFunctions): void;
  renderPageLayer?(props: PluginRenderPageLayer): ReactElement;
  renderViewer?(props: RenderViewer): Slot;
  uninstall?(pluginFunctions: PluginFunctions): void;
  onAnnotationLayerRender?(props: PluginOnAnnotationLayerRender): void;
  onCanvasLayerRender?(props: PluginOnCanvasLayerRender): void;
  onDocumentLoad?(props: PluginOnDocumentLoad): void;
  onTextLayerRender?(props: PluginOnTextLayerRender): void;
  onViewerStateChange?(viewerState: ViewerState): ViewerState;
}
